﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Common.Views;

namespace BL_WServices
{
    /// <summary>
    /// This is the Implementation of OrdersService which is bound by a ServiceContract
    /// </summary>
    [ServiceContract]
    public interface IOrdersService
    {
        /// <summary>
        ///  This will place an order for the client.
        ///  It will add the list of products, username, and orderID.
        ///  It will add the products, quantity, date of purchase and the username who bought the products.
        /// </summary>
        /// <param name="username">Of type string. The username who bought the products.</param>
        /// <param name="oID">Of type Guid. Used to enter a new OrderID of type guid</param>
        /// <param name="products">Of type List. List of products that will be placed in the order.</param>
        [OperationContract]
        void AddOrder(string username, Guid oID, List<CartView> products);

        /// <summary>
        /// Returns the list of products bought by a particular user
        /// </summary>
        /// <param name="username">Of type string. Used to get the list of products by username</param>
        /// <returns>Returns the list of products</returns>
        [OperationContract]
        IQueryable<OrdersView> GetProductsBoughtByUser(string username);

        /// <summary>
        /// This method is used to get the most purchased item from the database
        /// </summary>
        /// <returns>Returns the product which has been most purchased</returns>
        [OperationContract]
        IQueryable<StatisticalView> MostPurchasedItem();

        /// <summary>
        /// This method is used to get the most highly rated item from the database
        /// </summary>
        /// <returns>Returns the product which has been most highly rated</returns>
        [OperationContract]
        IQueryable<StatisticalView> HighlyRatedItem();

        /// <summary>
        /// This method is used to get the highest number of faults for 10 products
        /// </summary>
        /// <returns>Returns 10 products which have the highest number of faults</returns>
        [OperationContract]
        IQueryable<StatisticalView> HighestNumOfFaults();

        /// <summary>
        /// This method is used to get the lowest number of faults for 10 products
        /// </summary>
        /// <returns>Returns products which have the lowest number of faults</returns>
        [OperationContract]
        IQueryable<StatisticalView> LeastNumOfFaults();

        /// <summary>
        /// Save the View Items Purchased Details by username
        /// </summary>
        /// <param name="username">Of type string. Used to save the details according to username</param>
        [OperationContract]
        void SaveDetails(string username);
    }
}
